<?php
// Atividade.php
/**
 * Model de Atividade
 * @filesource  07/03/2010
 * @author      Estrada Virtual <http://estradavirtual.com.br>
 * @copyright   Copyright <2010> Estrada Virtual
 * @package     <<application>>
 * @subpackage  <<application>>.application.models
 * @version     $Id$
 */
class Atividade extends Zend_Db_Table {
    protected $_name = 'atividade';
    protected $_dependentTables  = array( 'Inscricao' );
    protected $_primary = array('id');

    protected $_referenceMap = array(
            'Usuario' => array(
                            'columns'       => 'id_palestrante',
                            'refTableClass' => 'Usuario',
                            'refColumns'    => 'id',
            ),
            'Sala' => array(
                            'columns'       => 'id_sala',
                            'refTableClass' => 'Sala',
                            'refColumns'    => 'id',
    ));

    public static function build() {
        return new self();
    }

    public function findAll() {
        $query = $this->getAdapter()
                ->select()
                ->from(array('a' => 'atividade'), '*')
                ->join(array('u' => 'usuario'),'a.id_palestrante = u.id','nome as nome_usuario')
                ->join(array('s' => 'sala'), 'a.id_sala = s.id','nome as nome_sala');
        return $query->query()->fetchAll();
    }
}
